﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace HP.Cachalote.WPF.Converters
{
    // Setup the UnfinishedTodoItemTreeView.MaxHeight based on UserControl.ActualHeight to show the scrollbar in the TreeView.
    public class NumberMultiplicationConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (targetType != typeof(double) && targetType != typeof(int))
            {
                throw new ArgumentException("The target must be a double or integer!");
            }

            if (parameter == null)
            {
                parameter = 1;
            }

            var result = System.Convert.ToDouble(value) * System.Convert.ToDouble(parameter);
            return System.Convert.ToInt32(result);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
